App({
  onLaunch: function (e) {
    var a = require("utils/onfire.js"), 
        t = this;

    t.globalData.launchOptions = e, 
    t.login(),
    
    wx.getSystemInfo({
      success: function (e) {
        t.globalData.systemInfo = e;
      }
    }), 
    
    wx.getLocation({
      success: function (e) {
        t.globalData.locationInfo = e;; 
        a.fire("location", e);
      }
    });
    console.log(t);
  },

  onShow: function () {
    // console.log('onshow');
    var e = require("utils/onfire.js"), 
        a = getCurrentPages();
    a.length && a[a.length - 1].route.indexOf("errand/_/index") >= 0 && e.fire("refreshHomeOrders");
  },

  id: "wx30ffb508cff9a8bf",
  baiduMapAK: "zVqnAl7Mkeumbfy1oiPrgUNhESIkKiRT",
  globalData: {
    siteUrl: "https://student.william-tse.com",
    isDebugger: !1,
    disableLoading: !1,
    userInfo: null,
    locationInfo: null,
    schoolInfo: null,
    launchOptions: null,
    settingInfo: null,
    systemInfo: {}
  },
  pageSize: 10,
  require: require,
  getSettings: function () {
    return this.getStorage("settings");
  },
  getStorage: function (e) {
    var a = wx.getStorageSync(e) || {};
    return a.save = function () {
      var a = {};
      for (var t in this) "save" != t && (a[t] = this[t]);
      wx.setStorageSync(e, a);
    }, a;
  },


  login: function () {
    console.log('loginx');
    var e = this, 
    a = (require("utils/util.js"), 
    require("utils/api.js")), 
    t = require("utils/onfire.js"), 
    n = function (n) {
      // a.loginWechat({
      //   code: n || "",
      //   referrerId: ""
      // }, function (a) {
      //   var n = e.getSettings();
      //   n.SessionId = a.SessionId, n.UserType = a.Type, n.save(), e.globalData.userInfo = a,
      //     t.fire("login", a);
      // });

      // t.fire('loginCeshi',n);
    };

    wx.login({
      success: function (e) {
        console.log(e);
        n(e.code);
      }
    });
  },

  authorizeCallback: function (e, a) {
    var t = this, n = require("utils/util.js"), r = require("utils/api.js"), i = {
      AvatarUrl: a.avatarUrl,
      NickName: a.nickName,
      Gender: a.gender
    };
    // console.log(e);
    // console.log(i);
    return false;
    // return t.globalData.userInfo || (t.globalData.userInfo = {}), t.globalData.userInfo.AvatarUrl == i.AvatarUrl && t.globalData.userInfo.NickName == i.NickName && t.globalData.userInfo.Gender == i.Gender || r.updateWechatInfo({
    //   NickName: i.NickName,
    //   AvatarUrl: i.AvatarUrl,
    //   Gender: i.Gender
    // }), n.extend(t.globalData.userInfo, i), e.data.userInfo ? e.setData({
    //   dialogType: null,
    //   userInfo: i
    // }) : e.setData({
    //   dialogType: null
    // }), i;
  },

  callAuthorize: function (e, a) {
    var t = this, n = t.globalData.userInfo;
    n && (n.NickName || n.AvatarUrl) && e.setData({
      dialogType: null
    });
    var r = function () {
      wx.getUserInfo({
        success: function (n) {
          var r = t.authorizeCallback(e, n.userInfo);
          a && a(r);
        }
      });
    };
    wx.getSetting({
      success: function (a) {
        a.authSetting["scope.userInfo"] ? r() : e.setData({
          dialogType: "authorize"
        });
      }
    });
  }

});